<template>
	<view>
		<view class="wrap safe-area" v-if="userInfo">
			<view class="wrap-content flex column align-center">
				<view class="title">
					已认证实名信息
				</view>
				
				<view class="avatar-box" @click="onAvatar">
					<image class="avatar" mode="aspectFill" :src="userInfo.avatar" />
				</view>
				
				<view class="nickname" @click="onNickName">
					{{ userInfo.nickname }}
				</view>
				
				<view class="auth-info flex column">
					<view class="auth-item flex align-center just-between" @click="onUserName">
						<view class="left">
							真实姓名
						</view>
						
						<view class="right">
							{{ $filters.onNameStar(userInfo.username) }}
						</view>
					</view>
					
					<view class="auth-item flex align-center just-between">
						<view class="left">
							证件类型
						</view>
						
						<view class="right">
							居民身份证
						</view>
					</view>
					
					<view class="auth-item flex align-center just-between" @click="onIdCard">
						<view class="left">
							证件号码
						</view>
						
						<view class="right">
							{{ $filters.onIdCardStar(userInfo.idCard) }}
						</view>
					</view>
				</view>
			</view>
			
			<view class="wrap-bottom">
				
			</view>
			
			
		</view>
		
		<popupVue
			:isShow.sync="isShowPopup"
			:changeKey="changeKey"
			@onRefresh="onGetUserInfo()"
		/>
	</view>
</template>

<script>
	import popupVue from "@/components/popup/popup.vue";
	export default {
		components: {
			popupVue
		},
		data() {
			return {
				userInfo: null,
				isShowPopup: false,
				changeKey: "",
			};
		},
		onShow() {
			this.onGetUserInfo();
		},
		methods: {
			/**
			 * 头像
			 */
			onAvatar() {
				this.$filters.onChooseImage(1, list => {
					var img = list[0];
					var obj = {...this.$stoarge.getUserInfo()};
					obj.avatar = img;
					this.$stoarge.setUserInfo(obj);
					
					this.onGetUserInfo();
				})
			},
			/**
			 * 昵称
			 */
			onNickName() {
				this.changeKey = "nickname";
				this.isShowPopup = true;
			},
			
			/**
			 * 姓名
			 */
			onUserName() {
				this.changeKey = "username";
				this.isShowPopup = true;
			},
			/**
			 * 身份证号
			 */
			onIdCard() {
				this.changeKey = "idCard";
				this.isShowPopup = true;
			},
			
			
			/**
			 * 获取个人信息
			 */
			onGetUserInfo() {
				this.userInfo = this.$stoarge.getUserInfo();
			},
		}
	}
</script>

<style lang="scss">
	.wrap {
		width: 100vw;
		height: 100vh;
		box-sizing: border-box;
		padding: 0rpx 50rpx;
		gap: 50rpx;
		
		.wrap-content {
			flex: 1;
			margin-top: 100rpx;
			width: 100%;
			overflow: hidden;
			
			.title {
				color: #000000;
				font-size: 36rpx;
				font-weight: bold;
			}
			
			.avatar-box {
				margin-top: 50rpx;
				width: 150rpx;
				height: 150rpx;
				border-radius: 100%;
				border: 2rpx solid #EEEEEE;
				overflow: hidden;
				
				.avatar {
					width: 100%;
					height: 100%;
				}
			}
			
			.nickname {
				margin-top: 30rpx;
				color: #000000;
				font-size: 30rpx;
			}
			
			.auth-info {
				margin-top: 40rpx;
				width: 100%;
				overflow: hidden;
				border-radius: 20rpx;
				background-color: #F2F2F2;
				padding: 30rpx;
				box-sizing: border-box;
				gap: 30rpx;
				
				.auth-item {
					width: 100%;
					overflow: hidden;
					
					.left {
						color: #666666;
						font-size: 30rpx;
					}
					
					.right {
						color: #000000;
						font-size: 30rpx;
					}
				}
			}
		}
	
		.wrap-bottom {
			width: 100%;
			overflow: hidden;
		}
	}
</style>
